#pragma once
#include "PowerFlow_Mo.h"

#define DifferError 0.00001    //两个值相减的误差值;
#define CurrentError 0.001    //电流误差值;
#define PowerError  0.01     //功率流误差值;
#define  PrecisionNumber 4   //电压值小数点数目;

class HBaseView;
class CMoSchematicConnector;

class POWERFLOW_MO CPowerFlow_MoInterface
{
public:
	CPowerFlow_MoInterface(void);	
	~CPowerFlow_MoInterface(void);

	bool IsMoMergeLayer() const { return m_bMoIsMergeLayer; }
	void SetMoIsMergeLayer(bool val) { m_bMoIsMergeLayer = val; }
	
	virtual void SetDisplayPowerFlow(bool bVal) { m_bShowPowerFlow = bVal; }

	virtual void OutputDynamicComponentInfo( HBaseView* pHView )= 0;

	virtual CString GetActiveLayerMoParams(HBaseView* pHView)=0;
	//sParamsDataֵΪname,type,value,name,type,value,....;
	virtual void UpdatePowerFlowMoParamsValue(HBaseView* pHView,CString sParamsData/*,int nPositive*/)=0; 
	virtual bool DisplayPowerFlowAnimation( HBaseView* pHView )=0;
	virtual bool StopPowerFlowAnimation( HBaseView* pHView );
	virtual bool IsDeviceCloseSwitch(HBaseView* pHView,CDeviceDisplayObj* pDevDis)=0;
	
	virtual CLayer* GetAnimationFlowLayer(HBaseView* pHView)=0;

	void CreateWireTrackerAnimation(CDisplayObj* pSchWireDisObj,HBaseView* pHView,bool bReverse);
	void DeleteWireTrackerAnimation(CDisplayObj* pSchWireDisObj,HBaseView* pHView);
	void HideOrShowSchWireAssoDisObj(CWireDisplayObj* pSchWireDisObj,HBaseView* pHView,bool bShow);
	void HideOrShowBusWireAssoDisObj(CSchematicBusDisplayObj* pBusDisObj,HBaseView* pHView,bool bShow);
	WireDirection GetDirectionOfSchBusLastSeg( CSchematicBusDisplayObj* pSchBusDis );

	CString GetOutputDynamicComponentVariableInfo();

	CString GetPowerFlowParams() const { return m_strPowerFlowParams; }
	void SetPowerFlowParams(CString val) { m_strPowerFlowParams = val; }

protected:
	void SetDeviceSwitchStatus();
	void SaveDeviceAndConnDisObjColor();
	void RevertDeviceAndConnDisObjColor();
	void RevertDeviceAndConnAllDisObjColor( CDeviceDisplayObj* pDevDisObj );
	bool IsDeviceLoad(CDeviceDisplayObj* pDevDis);
	void ClearSwitchDeviceVec();

	void AddVariableInfo(CString strName,int ref);
	bool IsPowerSupplySystem( CSubSystem*pSubSys);
protected:
	vector<CDeviceDisplayObj*> m_vecSwitchDevice;                  //动画流程层的设备显示对象;
	map<CDisplayObj*,vector<vector<double>>> m_mapDisFormerColor;  //所有设备显示对象及其电连接器;
	map<string,string> m_mapDevCode2Type; //设备代号-类型;

	map<CString,int> m_VarName2RefMap;  //变量名-变量引用（保存输出BCG动态组件面板变量信息）

	bool m_bMoIsMergeLayer; //模型是否为合并层;
	CString m_strPowerFlowParams; //功率流参数


	bool m_bShowPowerFlow; //显示功率流;
};

